<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    ul li {
        display: block;
        width: 50px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        border : 1px solid orange;
    }
    ul .li1:hover {
        background-color: #ccc;
    }
    .li2 {
        border-top: none;
        display: none;
    }
    ul li:hover {
        color: orange;
        background-color: #fff5da;
    }
</style>
<body>
        <!-- 1.获取要操作的“微博”和下拉菜单元素

        2.给“微博”注册鼠标移入事件，显示下拉菜单
        
        3.给“微博”注册鼠标移出事件，隐藏下拉菜单 -->
        <ul>
            <li class="li1"><em>微博</em></li>
            <li class='li2'>私信</li>
            <li class='li2'>评论</li>
            <li class='li2'>@我</li>
        </ul>
        <script>
            var li1 = document.querySelector('.li1')
            var li2 = document.querySelectorAll('.li2')
            li1.onmouseover = function(){
            for (i = 0; i<li2.length;i++){
                li2[i].style.display = 'block'
            }
            }
           li1.onmouseout = function(){
            for (i = 0; i<li2.length;i++){
                li2[i].style.display = 'none'
            }
               
           }
            
        </script>
</body>
</html>